/*
 * @Description: 
 * @Version: 1.0
 * @Autor: c-jack.qian
 * @Date: 2021-03-18 18:08:30
 * @LastEditors: c-jack.qian
 * @LastEditTime: 2021-03-18 19:26:49
 */
class Container {
    static of(value) {
        return new Container(value);
    }
    constructor(value) {
        this._value = value;
    }
    map(fn) {
        return Container.of(fn(this._value));
    }
}

// Maybe 函子 用来处理输入空值的情况
class Maybe {
    static of(initialValue) {
        return new Maybe(initialValue);
    }
    constructor(value) {
        this._value = value;
    }
    // 执行一个函数对值进行处理，来映射另一个函子
    map(fn) {
        return this.isNothing() ? this : Maybe.of(fn(this._value));
    }
    isNothing() {
        return this._value === null || this._value === undefined;
    }
}
module.exports = {
    Container,
    Maybe
}